import stringUtils from 'string-utils.js';

function getIndexColor(index) {
  var color = {
    from_color: '',
    to_color: ''
  }
  switch (index) {
    case 0: //0
      color.from_color = '#eab15d'
      color.to_color = '#ffa631'
      break
    case 1:
      color.from_color = '#ec7856'
      color.to_color = '#f36838'
      break
    case 2:
      color.from_color = '#c7e771'
      color.to_color = '#a4de08'
      break
    case 3:
      color.from_color = '#6ce5df'
      color.to_color = '#3eede7'
      break
    case 4:
      color.from_color = '#e23973'
      color.to_color = '#f00056'
      break
    case 5:
      color.from_color = '#4ba1c9'
      color.to_color = '#177cb0'
      break
    case 6:
      color.from_color = '#8793e2'
      color.to_color = '#4b5cc4'
      break
    case 7:
      color.from_color = '#4ad557'
      color.to_color = '#00bc12'
      break
    case 8:
      color.from_color = '#8793e2'
      color.to_color = '#4b5cc4'
      break
    case 9:
      color.from_color = '#ed423f'
      color.to_color = '#f05654'
      break
    default:
      color.from_color = '#e58d4d'
      color.to_color = '#ff8936'
      break
  }
  return color
}

function getGridWithColor(grids) {
  for (let i = 0; i < grids.length; i++) {
    var color = getIndexColor(i)
    // console.log("getGridWithColor",color)
    // console.log("getGridWithColor" + grids[i].title + "ss")
    if (stringUtils.trim(grids[i].title) == "开发中") {
      grids[i].from_color = '#676a6a'
      grids[i].to_color = '#929494'
    } else {
      grids[i].from_color = color.from_color
      grids[i].to_color = color.to_color
    }
  }
  console.log("getGridWithColor", grids)
  return grids;
}

module.exports = {
  getGridWithColor
}